$(function () {
  $(document).ready(function () {
    $(".layui-container").particleground({
      dotColor: "#7ec7fd",
      lineColor: "#7ec7fd",
    });
  });
});

var form = layui.form;
$(".layui-form").submit(function (e) {
  e.preventDefault(); //阻止默认行为
  var fd = $(this).serialize(); //获取表单数据
  $.ajax({
    type: "post",
    url: "/api/login",
    data: fd,
    success: function (res) {
      if (res.status === 0) {
        localStorage.setItem("mytoken", res.token);
        location.href = "./index.html";
      } else {
        layer.msg(res.message);
      }
    },
  });
});
